/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: ProxyErrorCode.java   2020-10-07 23-13-23
 * Author: Evan
 */
package cn.datacare.orm.mapper.proxy;

import cn.datacare.orm.exception.ErrorCode;

import java.text.MessageFormat;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-07 23-13-23
 * @since V1.0
 */
public enum ProxyErrorCode implements ErrorCode {
    ANNOTATION_DEFINE_ERROR_RETURN("5001","SqlProvider类[{0}]的方法[{1}]返回值必须为{2}类型"),
    ANNOTATION_DEFINE_ERROR_HAS_ARGS("5004", "实例化{0}失败，请检查是否有公有的无参构造"),
    ANNOTATION_DEFINE_ERROR_PROVIDER_METHOD("5003", "调用Provider方法出错:{0}"),
    ANNOTATION_DEFINE_ERROR_NO_METHOD("5004", "未能从{0}获取到{2}方法");
    /***
     * 错误
     */
    private final String code;
    /***
     * 错误信息
     */
    private final String message;

    ProxyErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /***
     * 错误代码
     * @return String String
     */
    @Override
    public String getCode() {
        return this.code;
    }

    /***
     * 异常消息
     * @return String String
     */
    @Override
    public String getMessage() {
        return this.message;
    }

    /***
     * 参数处理消息
     * @param params
     * @return String
     */
    @Override
    public String getMessage(Object... params) {
        return MessageFormat.format(this.message, params);
    }
}
